home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1994 / MacHack 1994.toast / MacHack™94 / Miscellaneous / Randy Thelen / ThreadedSort / Sort ƒ / SortPicts.cp < prev    next >
Encoding:
Text File  |  1994-06-26  |  2.7 KB  |  172 lines  |  [TEXT/MMCC]

  1.  
  2.  
  3. #include "SortPicts.h"
  4.  
  5. /*
  6.  *    Constructor
  7.  *    -----------
  8.  *
  9.  *    Call CreateWindow to make the new window.
  10.  */
  11. SortPicts::SortPicts()
  12. {
  13.     CreateWindow(kNormalWindow);
  14. }
  15.  
  16.  
  17. /*
  18.  *    Destructor
  19.  *    ----------
  20.  *
  21.  *    Beavis says, "Uh, uhhh, hhuhh, don't dispose memory ... thats cool."
  22.  */
  23. SortPicts::~SortPicts()
  24. {
  25. }
  26.  
  27.  
  28.  
  29.  
  30. /*
  31.  *    MakeNewWindow
  32.  *    -------------
  33.  *
  34.  *    This routine will create a GWorld with a given name.
  35.  *    In theory, the name would be passed around some how
  36.  *    (I stress the somehow ...) so that various windows
  37.  *    could be used.
  38.  *
  39.  *    Notice the MakeThread call.  That is not a direct call
  40.  *    to the ThreadManager.  Go look at the routine to see
  41.  *    how it works.  (This is a "well de-composed" program.)
  42.  */
  43. WindowPtr
  44. SortPicts::MakeNewWindow(WindowPtr behindWindow)
  45. {
  46.     if( PrepareGWorld( "\pApple, IBM, Motorola"))
  47.     {
  48.         me = GetNewCWindow(128,nil,behindWindow);
  49.         if( me)
  50.         {
  51.             SetWTitle( me, "\pApple, IBM, Motorola");
  52.             SizeWindow( me, pictWidth, windPictRect.bottom, false);
  53.             ShowWindow( me);
  54.             
  55.             MakeThreaded();
  56.         }
  57.         
  58.         
  59.     }
  60.         
  61.     return me;
  62. }
  63.  
  64.  
  65. void
  66. SortPicts::Activate(Boolean /* activating */)
  67. {
  68. //    DrawGrowIcon(fWindow);
  69. }
  70.  
  71.  
  72. void
  73. SortPicts::AdjustCursor(EventRecord * /* anEvent */)
  74. {
  75. }
  76.  
  77.  
  78. /*
  79.  *    Draw
  80.  *    ----
  81.  *
  82.  *    Do your basic stuff.
  83.  */
  84. void
  85. SortPicts::Draw(void)
  86. {
  87.     return;
  88.     sortPixmap = GetGWorldPixMap( sortGWorld);
  89.     
  90.     LockPixels( sortPixmap);
  91.     
  92.     CopyBits( (const BitMap *) *sortPixmap, 
  93.               (const BitMap *) (*(((CWindowPtr)me)->portPixMap)),
  94.               &sortRect,&windPictRect,srcCopy,nil);
  95.     
  96.     UnlockPixels( sortPixmap);
  97. }
  98.  
  99.     
  100. void
  101. SortPicts::KeyDown(EventRecord * /* anEvent */ )
  102. {
  103.     this->Select();
  104. }
  105.  
  106.  
  107. void
  108. SortPicts::AdjustForNewWindowSize(Rect * /* oldSize */, Rect * /* newSize */)
  109. {
  110. //    DrawGrowIcon(fWindow);    
  111. }
  112.  
  113.  
  114. /*
  115.  *    Close
  116.  *    -----
  117.  *
  118.  *    The key here is ... DisposeThread.
  119.  */
  120. Boolean
  121. SortPicts::Close(void)
  122. {
  123.     StandardCloseResult    result;
  124.     Str255                title;
  125.     
  126.     GetWTitle(this->fWindow,title);
  127.     result = StandardCloseDocument(LMGetCurApName(),title,false,false);
  128.  
  129.     if (result != kCancelSaveDocument)
  130.     {
  131.         DisposeThread( threadInfo, nil, true);
  132.         return TWindow::Close();
  133.     }
  134.     return false;
  135. }
  136.  
  137.  
  138. OSErr
  139. SortPicts::HandleDrag(DragTrackingMessage dragMessage,DragReference theDrag)
  140. {
  141.     RgnHandle    hiliteRgn = NewRgn();
  142.     
  143.     switch (dragMessage)
  144.     {
  145.         case    dragTrackingEnterWindow:
  146.             SetRectRgn( hiliteRgn,
  147.                         fWindow->portRect.left,
  148.                         fWindow->portRect.top,
  149.                         fWindow->portRect.right,
  150.                         fWindow->portRect.bottom);
  151.             ShowDragHilite(theDrag,hiliteRgn,true);
  152.             break;
  153.             
  154.         case    dragTrackingLeaveWindow:
  155.             HideDragHilite(theDrag);
  156.             break;
  157.             
  158.         default:
  159.             break;
  160.     }
  161.     
  162.     DisposeRgn(hiliteRgn);
  163.     return(noErr);
  164. }
  165.  
  166.     
  167. OSErr
  168. SortPicts::HandleDrop(DragReference /* theDrag */)
  169. {
  170.     return(noErr);
  171. }
  172.